import type { OrderPre, AddressItem } from '@/types/medicine'
import { request } from '@/utils/request'

export const getMedicalOrderPre = (prescriptionId: string) => {
  return request.get<OrderPre>('/patient/medicine/order/pre', {
    params: {
      prescriptionId,
    },
  })
}

export const getAddressList = () => {
  return request.get<AddressItem[]>('/patient/order/address')
}

export const createMedicalOrder = (data: { id: string; addressId: string; couponId?: string }) => {
  return request.post<{ id: string }>('/patient/medicine/order', data)
}

export const getMedicalOrderDetail = (id: string) => {
  return request.get<any, OrderDetail>(`/patient/medicine/order/detail/${id}`)
}

// 获取药品订单物流信息
export const getMedicalOrderLogistics = (id: string) => {
  return request.get<any, Express>(`/patient/order/${id}/logistics`)
}
